home *** CD-ROM | disk | FTP | other *** search
/ PC Open 93 / PC Open 93 CD 2.bin / PDF / webdeveloper / lezione_4 / listato 8.txt < prev    next >
Encoding:
Text File  |  2004-01-07  |  2.3 KB  |  135 lines

  1. LISTATO 8 รป GESTIONE_MODIFICA.ASP
  2.  
  3. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4.  
  5. <html>
  6. <head>
  7.     <title>Gestione foto di Mario Rossi</title>
  8. </head>
  9.  
  10. <body>
  11.  
  12. <h1>Gestione foto</h1>
  13.  
  14.  
  15. <%
  16.  
  17. Const adOpenForwardOnly = 0
  18. Const adLockReadOnly = 1
  19.  
  20. Dim contatore
  21. Dim sql1,sql2
  22. Dim conn, rs
  23. Dim pagNum
  24. Dim pagSize
  25. Dim i,j
  26.  
  27. pagSize = 2
  28.  
  29. Set conn = Server.CreateObject("ADODB.Connection")
  30. conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/foto2.mdb")
  31.  
  32. sql1 = "SELECT count(nome) AS contatore FROM Foto"
  33. sql2 = "SELECT * FROM Foto ORDER BY Data DESC"
  34.  
  35. Set rs = Server.CreateObject("ADODB.RecordSet")
  36. rs.Open sql1, conn, adOpenForwardOnly, adLockReadOnly
  37.  
  38. contatore = rs("contatore")
  39.  
  40. rs.Close()
  41.  
  42.  
  43. 'Estrae il numero di pagina
  44. pagNum = cint(request.QueryString("pag"))
  45. If pagNum = 0 Then pagNum = 1
  46.  
  47. 'Imposta la dimensione della pagina (il numero massimo di elementi da far comparire per ogni pagina)
  48. rs.PageSize = pagSize
  49.  
  50. rs.Open sql2, conn, 3, adLockReadOnly
  51.  
  52. %>
  53.  
  54. Foto presenti nella base di dati: <%=contatore%><br><br>
  55. Inserisci una <a href="inseriscifoto.asp">nuova foto</a>
  56. <%
  57.  
  58.  
  59. rs.AbsolutePage = pagNum
  60.  
  61. for i = 1 to pagSize
  62.  
  63.     if not rs.EOF Then
  64.  
  65.         if i mod 2 = 0 then
  66.             strColor="#3333CC"
  67.         else
  68.             strColor="#FF0033"
  69.         end if
  70.  
  71. %>
  72.  
  73. <li>
  74.     <a style="color:<%=strColor%>" href="dettagliofoto.asp?nome=<%=rs("Nome")%>"><%=rs("Titolo")%>, scattata a <%=rs("Luogo")%></a>
  75.     [<a href="modificafoto.asp?nome=<%=rs("nome")%>">modifica</a>]
  76. </li>
  77.  
  78. <%
  79.         rs.movenext
  80.  
  81.     Else
  82.  
  83.         Exit For
  84.  
  85.     End If
  86.  
  87.  
  88. next
  89.  
  90. %>
  91.  
  92. <br><hr><br>
  93.  
  94. <div align="left">
  95.  
  96. <%
  97.     If pagNum > 1 Then
  98. %>
  99.     <a href="<%=request.ServerVariables("PATH_INFO")%>?pag=<%=pagNum -1%><%=strTipo%>">«</a>
  100. <%
  101.     End If
  102. %>
  103.  
  104. <% for j = 1 to rs.PageCount %>
  105.     <% if j = pagNum then %>
  106.         <%=j%>
  107.     <% else %>
  108.         <a href="<%=request.ServerVariables("PATH_INFO")%>?pag=<%=j%><%=strTipo%>"><%=j%></a>
  109.     <% end if %>
  110. <% next %>
  111.  
  112. <%
  113.     If pagNum < rs.PageCount Then
  114. %>
  115.     <a href="<%=request.ServerVariables("PATH_INFO")%>?pag=<%=pagNum+1%><%=strTipo%>">»</a>
  116. <%
  117.     End If
  118. %>
  119.  
  120. </div>
  121.  
  122. <%
  123. rs.close
  124. set rs = nothing
  125. conn.close
  126. set conn = nothing
  127.  
  128. %>
  129.  
  130. </ul>
  131.  
  132. </body>
  133. </html>
  134.  
  135.